{extend name="layout/iframe" /}

{block name="pagecss"}
<style>
    .layui-form-label {
        width: 160px;
    }
    .layui-input-block {
        margin-left: 200px;
    }
</style>
{/block}

{block name="content"}
<div class="layui-card-body layui-layout-admin" style="padding: 15px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-col-md9 layui-col-xs12">
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md9 layui-col-xs7">
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label"><span class="required">*</span>是否启用</label>
                        <div class="layui-input-inline">
                            <input type="checkbox" name="m_status" {if condition="($info.m_status == 1)"}checked=""{/if} lay-skin="switch" lay-text="启用|禁用"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>启用</em><i></i></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="required">*</span>会员账号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input account_number" name="account_number" value="{$info.account_number}" data-account_number="{$info.account_number}" maxlength="20" lay-verify="account_number" placeholder="会员账号" autocomplete="off">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md3 layui-col-xs5">
                    <div id="upload-image">
                        <div class="layui-upload-list thumbBox mag0 magt3" id="upload-btn" data-multi="false">
                            <input type="hidden" class="layui-input" name="img_url" value="{$info.img_url}">
                            <img class="layui-upload-img thumbImg" src="{$info.img_url}">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>姓名</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="name" value="{$info.name}" lay-verify="name" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>性别</label>
            <div class="layui-input-block">
                <select name="sex" lay-verify="required">
                    <option value="1" {if condition="($info.sex == 1)"}selected=""{/if}>男</option>
                    <option value="2" {if condition="($info.sex == 2)"}selected=""{/if}>女</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>生日</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input lay_date" name="birthday" value="{$info.birthday}" lay-verify="required" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">账号余额</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="balance" value="{$info.balance / 100 ?: ''}" lay-verify="balance" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">会员积分</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="integral" value="{$info.integral ?: ''}" lay-verify="integral" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>会员等级</label>
            <div class="layui-input-block">
                <select name="member_level_id" lay-verify="required">
                    <option value="">请选择</option>
                    {foreach name="memberLevels" item="level"}
                        <option value="{$level.id}" {if condition="($info.member_level_id == $level.id)"}selected=""{/if}>{$level.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><!--<span class="required">*</span>-->开通日期</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input start_date" name="open_time" value="{$info.open_time|substr=0,10}" placeholder="" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><!--<span class="required">*</span>-->到期日期</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input end_date" name="end_time" value="{$info.end_time|substr=0,10}" placeholder="" autocomplete="off">
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><!--<span class="required">*</span>-->开通门店</label>
            <div class="layui-input-block">
                <select name="open_store_id">
                    <option value="">请选择</option>
                    {foreach name="stores" item="store"}
                        <option value="{$store.id}" {if condition="($info.open_store_id == $store.id)"}selected=""{/if}>{$store.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <input type="hidden" name="id" value="{$info.id}">

        <div class="layui-form-item layui-row layui-col-xs12">
            <div class="layui-input-block">
                <div class="layui-footer">
                    <button type="button" class="layui-btn layui-btn-primary close-btn">取消</button>
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="laySave">保存 <i class="layui-icon">&#xe609;</i></button>
                </div>
            </div>
        </div>
    </form>
</div>

<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/savepost')}">
<input type="hidden" class="check_account_number_url" value="{:url('admin/'.strtolower($model).'/checkAccountNumber')}">
{/block}

{block name="pagescript"}
<script src="__STATIC__/admin/js/qiniu/plupload.full.min.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniu.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniuConfig.js" type="text/javascript"></script>

<script src="__STATIC__/admin/pages/js/uploadfile.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/member.js" type="text/javascript"></script>
<script>
    layui.use(['layer', 'laydate'], function(){
        var $ = layui.jquery,
            laydate = layui.laydate;
        // 执行一个laydate实例
        var startDate = laydate.render({
            elem: '.start_date', //指定元素
            type: 'date',
            format: 'yyyy-MM-dd',
            trigger: 'click',
            done: function(value, date){
                //endDate.config.min.year = date.year;
                //endDate.config.min.date = date.date;

                endDate.config.min.year = date.year;
                endDate.config.min.month = date.month - 1;
                var day = date.date;
                if(date.hours == 23 && date.minutes == 59 && date.seconds == 59){
                    day = day + 1;
                }else{
                    endDate.config.min.hours = date.hours;
                    endDate.config.min.minutes = date.minutes;
                    endDate.config.min.seconds = date.seconds;
                }
                endDate.config.min.date = day;
            }
        });

        var endDate = laydate.render({
            elem: '.end_date',
            type: 'date',
            format: 'yyyy-MM-dd',
            trigger: 'click',
            done: function(value, date){
                //startDate.config.max.year = date.year;
                //startDate.config.max.date = date.date;

                startDate.config.max.year = date.year;
                startDate.config.max.month = date.month - 1;
                var day = date.date;
                if(date.hours == 0 && date.minutes == 0 && date.seconds == 0){
                    day = day - 1;
                }else{
                    startDate.config.max.hours = date.hours;
                    startDate.config.max.minutes = date.minutes;
                    startDate.config.max.seconds = date.seconds;
                }
                startDate.config.max.date = day;
            }
        });

        var layDate = laydate.render({
            elem: '.lay_date',
            type: 'date',
            format: 'yyyy-MM-dd',
            trigger: 'click',
            done: function(value, date){
                //
            }
        });
    });
</script>
{/block}